// SquirrelGame.cpp : Defines the entry point for the console application.
//
#include "Precomp.h"
#include "SQGame.h"
#include "mapformat.pb.h"
#include <PhysFS++.h>
#include "Logger.h"
#include <fstream>
#include "PostMortemDebug.h"

int main(int argc, char* argv[])
{
	GOOGLE_PROTOBUF_VERIFY_VERSION;
	ENABLE_CRASH_HANDLER;
	Logger logger;
	logger.addTarget(std::wcout);
	std::wfstream logfile(L"BGB.log",std::ios::out);
	logger.addTarget(logfile);
	{
		PhysFS::VFSManager filesystem(argv[0]);//init virtual file system
		SQGame game;
		if(game.init(argc,argv,L"config.nut"))
		{
			if(!game.run(L"main.nut"))
			{
				//std::cin.get();//pause to see the error
			}
		}
		else
		{
			Log("Error in initialization");	
			//std::cin.get();
		}
	}
	SquirrelVM::Shutdown();
	logfile.close();
	return 0;
}